<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%
    request.setAttribute("PAGE_TITLE", "改约");
%>
<jsp:include page="../../include/head.jsp"/>
<form class="form-horizontal" name="myForm" id="myForm" action="${BasePath}/order/reservation/save" method="post">
    <input type="hidden" name="id" value="${reservation.idOrder}"/>
    <input type="hidden" name="groupOrderId" value="${reservation.idGroupOrder}"/>
    <input type="hidden" name="reservationId" value="${reservation.id}"/>
    <table id="edittable" style="width:700px;">
        <tr>
            <td colspan="4" class="column_head" style="font-size:14px;font-weight:bold;">
                订单信息
            </td>
        </tr>
        <tr>
            <td class="column_name" style="width:15%">
                订单号
            </td>
            <td class="column_input" style="width:35%">
                ${reservation.orderNo}
            </td>
            <td class="column_name" style="width:15%">
                订单来源
            </td>
            <td class="column_input" style="width:35%">
                ${order.orderFrom}
            </td>
        </tr>
        <tr>
            <td class="column_name">
                购买人
            </td>
            <td class="column_input">
                ${reservation.buyUser}
            </td>
            <td class="column_name">
                有效期
            </td>
            <td class="column_input">
                <script>formatDate(${order.startDate});</script>
                至
                <script>formatDate(${order.endDate});</script>
            </td>
        </tr>
        <tr>
            <td class="column_name">
                邮寄地址
            </td>
            <td class="column_input">
                ${reservation.address}
            </td>
            <td class="column_name">
                &nbsp;
            </td>
            <td class="column_input" >
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="column_name">
                体检人姓名
            </td>
            <td class="column_input">
                ${reservation.endUser}
            </td>
            <td class="column_name">
                性别
            </td>
            <td class="column_input">
                ${reservation.sex}
            </td>
        </tr>
        <tr>
            <td class="column_name">
                年龄
            </td>
            <td class="column_input">
                ${reservation.age}
            </td>
            <td class="column_name">
                身份证号
            </td>
            <td class="column_input">
                ${reservation.idCard}
            </td>
        </tr>
        <tr>
            <td class="column_name">
                电话号码
            </td>
            <td class="column_input">
                <input type="text" name="phone" id="phone"
                       value="${reservation.phone}" size="25" maxlength="40"/>
            </td>
            <td class="column_name">
                手机
            </td>
            <td class="column_input">
                <input type="text" name="mobile" id="mobile"
                       value="${reservation.mobile}" size="25" maxlength="40"/>
            </td>
        </tr>
    </table>
    <table id="edittable" style="width:700px;">
        <tr>
            <td colspan="4" class="column_head" style="font-size:14px;font-weight:bold;">
                预约信息
            </td>
        </tr>
        <tr>
            <td class="column_name" style="width:15%">
                合作机构
            </td>
            <td class="column_input" style="width:35%">
                ${reservation.institutionName}
                <input type="hidden" id="idInstitution" name="idInstitution" value="${reservation.idInstitution}"/>
            </td>
            <td class="column_name" style="width:15%">
                套餐名称
            </td>
            <td class="column_input" style="width:35%">
                ${reservation.productName}
                <input type="hidden" id="idProduct" name="idProduct" value="${reservation.idProduct}"/>
            </td>
        </tr>
        <tr>
            <td class="column_name">
                成交价格
            </td>
            <td class="column_input">
                ${reservation.salePrice}
            </td>
            <td class="column_name">
            </td>
            <td class="column_input">
            </td>
        </tr>
        <tr>
            <td class="column_name">
                预约日期
            </td>
            <td class="column_input">
                <input type="text" name="reserveDate" id="reserveDate" value=""
                       size="25" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" />
            </td>

            <td class="column_name">
                预约分院
            </td>
            <td class="column_input">
                <c:choose>
                    <c:when test="institutionBranchList != null && institutionBranchList.size()>0">
                    <select id="branch" name="branch" style="width:200px;" required>
                        <option value="-1">请选择分院</option>
                        <c:forEach items="${institutionBranchList}" var="branch">
                            <option value="${branch.name}"
                                    <c:if test="${branch.name==reservation.branch}">selected="selected"</c:if> >${branch.name}</option>
                        </c:forEach>
                    </select>
                    </c:when>
                    <c:otherwise>
                        <input type="text" name="branch" value="${reservation.branch}" size="25" maxlength="20"/>
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
        <tr>
            <td class="column_name">
                预约备注
            </td>
            <td class="column_input" colspan="3">
                <input type="text" name="comments"
                       value="${reservation.comments}" size="84" maxlength="100"/>
            </td>
        </tr>
        <tr>
            <td class="column_name">
                订单客服备注
            </td>
            <td class="column_input" colspan="3">
                <input type="text" name="comment"
                       value="${order.comment}" size="86" maxlength="100"/>
            </td>
        </tr>
        <tr>
            <td colspan="4" class="column_bottom">
                <input name="submit" type="button" onclick="saveReservation()" value="提交" />
                <input name="reset" type="reset" id="reset" value="重置" />
            </td>
        </tr>
    </table>
</form>
</body>
</html>
<script>
    $(function(){
        setByIdFormatDate("reserveDate",'${reservation.reserveDate}');
    });

    function saveReservation() {
        /*var phone = $("#phone").val();
        var mobile = $("#mobile").val();
        if (phone == "" && mobile == "") {
            layer.msg('请填写联系电话!', {icon: 5});
            return false;
        }*/
        var reserveDate = $("#reserveDate").val();
        if (reserveDate == "") {
            layer.msg('请选择预约日期!', {icon: 5});
            return false;
        }
        $('#myForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                updateAlert(data.errdesc, 'alert-error');
            } else {
                window.location.href = window.location;
            }
        });
    }
</script>
